﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%--<div class="editor-label">
    <%: Html.Label("Picture Caption") %>
</div>
<div class="editor-field">
    <input type="text" name="PictureCaption" id="PictureCaption" value="" />
</div>--%>


<script type="text/javascript">

    function checkFileExtension(elem) {
        var filePath = elem.value;

        if (filePath.indexOf('.') == -1)
            return false;

        var validExtensions = new Array();
        var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();

        validExtensions[0] = 'jpg';
        validExtensions[1] = 'jpeg';
        validExtensions[2] = 'bmp';
        validExtensions[3] = 'png';
        validExtensions[4] = 'gif';   
      

        for (var i = 0; i < validExtensions.length; i++) {
            if (ext == validExtensions[i])
                return true;
        }

        alert('The file extension ' + ext.toUpperCase() + ' is not allowed!');
        elem.value = "";
        return false;
    }

</script>


<div class="editor-label">
    <%: Html.Label("Picture File") %>
</div>
<div class="editor-field">
    <input type="file" name="PictureFile" id="PictureFile" value="Browse" onchange="return checkFileExtension(this);" />
</div>
